﻿using PSI.Filters;
using PSI.Services;
using PSI.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PSI.Models;

namespace PSI.Controllers {
    public class LogController : PSIController {
        private UserService UserService { get { return new UserService(); } }

        public ActionResult Index() 
        {
            if (!new PermissionService().HasPermission(FIdConst.LOG)) {
                return Redirect("/");
            }

            ViewBag.UserName = UserService.GetLoginUserName();

            return View();
        }

        public ActionResult GetLogByPage(int page, int start, int limit) {
            LogService ls = new LogService();
            var data = ls.GetLog(page, start, limit);
            var totalCount = ls.GetLogTotalCount();

            return Json(new { totalCount = totalCount, logs = data },
                JsonRequestBehavior.AllowGet);
        }
    }
}
